

import UIKit

class ImportPassWordView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addSubview(self.importAccount)
        self.addSubview(self.lineView)

        self.importAccount.snp.makeConstraints { (make) in
            make.left.equalTo(self.snp.left).offset(0)
            make.right.equalTo(self.snp.right).offset(0)
            make.bottom.equalTo(self.snp.bottom).offset(0)
            make.top.equalTo(self.snp.top).offset(0)
        }
        
        self.lineView.snp.makeConstraints { (make) in
            make.left.equalTo(self.snp.left).offset(0)
            make.right.equalTo(self.snp.right).offset(0)
            make.bottom.equalTo(self.snp.bottom).offset(0)
            make.height.equalTo(1)
        }
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func clockRightImgBtn(sender:UIButton) {
        self.importAccount.isEnabled = false
        sender.isSelected = !sender.isSelected
        self.importAccount.isSecureTextEntry = sender.isSelected
        self.importAccount.isEnabled = true
        self.importAccount.becomeFirstResponder()
    }
    
    @objc func textFieldDidChange() {
        
    }
    
    lazy var importAccount : UITextField =  {
        let importAccount = UITextField()
        importAccount.textColor = UIColor.init(hexString: "#333333")
        importAccount.font = UIFont.systemFont(ofSize: 18)
        importAccount.placeholder = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_Password)
        importAccount.rightViewMode = .always
        let rightImg = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 30, height: 45))
        rightImg.setImage(UIImage.init(named: "login_on"), for: .normal)
        rightImg.setImage(UIImage.init(named: "login_off"), for: .selected)
        rightImg.addTarget(self, action: #selector(clockRightImgBtn), for: .touchUpInside)
        rightImg.isSelected = true
        importAccount.rightView = rightImg
        importAccount.isSecureTextEntry = true
        importAccount.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
        return importAccount
    }()
    
    lazy var lineView : UIView =  {
        let lineView = UIView()
        lineView.backgroundColor = UIColor.init(hexString: "#CACACA")
        return lineView
    }()
}
